ARD2  RC2
Airbag Reference Demonstrator using MPC5604P
MPC55xx_init_flash.c
00001 
00002 /*
00003  *
00004  * FILE : MPC55xx_init.c
00005  *
00006  * DESCRIPTION:
00007  *  This file contains the MPC55xx derivative needed initializations. 
00008  *  usr_init() is called by the startup code of the application at initialization time
00009  *  You can add needed hardware initializations here.
00010  *  This file also contains the RCHW and Reset Vector setup:
00011 /*  The chip is by default setup to boot from internal Flash and the watchdog is disabled.
00012  */
00013 
00014 #include "Exceptions.h"     /* IVPR and default exception handlers setup */
00015 #include "IntcInterrupts.h" /* INTC Interrupts Requests configuration */
00016 #include "MPC5604P_HWInit.h"
00017 
00018 #pragma section code_type ".init"
00019 
00020 #define INIT_DERIVATIVE_INTERNAL_SETUP 1
00021 #define INIT_EXTERNAL_BUS_INTERFACE_SETUP 0
00022 
00023 #ifndef INIT_DERIVATIVE_INTERNAL_SETUP
00024 #pragma error INIT_DERIVATIVE_INTERNAL_SETUP should be defined !
00025 #endif
00026 
00027 #ifndef INIT_EXTERNAL_BUS_INTERFACE_SETUP
00028 #pragma error INIT_EXTERNAL_BUS_INTERFACE_SETUP should be defined !
00029 #endif
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 extern __asm void __startup();
00036 __asm void usr_init();
00037 /*lint -esym(752,__start) */
00038 
00039 #ifdef __cplusplus
00040 }
00041 #endif
00042 
00043 /*****************************************************************/
00044 /* usr_init():                                                   */
00045 /*   Define here the needed hardware initializations at startup  */
00046 
00047 __asm void usr_init()
00048 {
00049     /* Add needed hardware initializations in this function */
00050     nofralloc
00051 
00052     mflr     r30                         /* Save off return address in NV reg */
00053 
00054 #if INIT_DERIVATIVE_INTERNAL_SETUP==1
00055     bl      INIT_Derivative              /* Derivative specific hardware initializations */
00056 #endif
00057 #if INIT_EXTERNAL_BUS_INTERFACE_SETUP==1
00058     bl      INIT_ExternalBusAndMemory    /* Set up access to external memory (inc. chip select and MMU) */
00059 #endif
00060     bl      EXCEP_InitExceptionHandlers   /* Set up Default Exception handling */
00061     bl      INTC_InitINTCInterrupts       /* Set up INTC Interrupts Requests handling */
00062 
00063     mtlr    r30                          /* Get saved return address */
00064 
00065     blr
00066 }
00067 
00068 #ifdef __cplusplus
00069 extern "C" {
00070 #endif
00071 
00072 /**************************************************************/
00073 /* RCHW and Reset Vector setup:                               */
00074 /*   The chip is by default setup to boot from internal Flash */
00075 /*   and the watchdog is disabled.                            */ 
00076 
00077 typedef void (*resetfuncptr)(void);
00078 
00079 #pragma push /* Save the current state */
00080 #pragma section sconst_type ".__bam_bootarea"
00081 extern const unsigned long bam_rchw;
00082 extern const resetfuncptr bam_resetvector;
00083 
00084 /* RCHW_VALUE Flags */
00085 #define RCHW_WTE 0x0400L        /* Enable Watchdog */
00086 #define RCHW_VLE 0x0100L        /* Enable Variable Length Encoding*/
00087 #define RCHW_PS0_32BITS 0x0000L /* Boot from External Bus CS0, 32-bit CS0 port size. */
00088 #define RCHW_PS0_16BITS 0x0200L /* Boot from External Bus CS0, 16-bit CS0 port size. */
00089 #define RCHW_BOOTIDENTIFIER 0x005AL
00090 
00091 /* Used RCHW value: boot from internal flash, watchdog disabled */
00092 #if VLE_IS_ON == 1
00093 #define RCHW_VALUE RCHW_BOOTIDENTIFIER|RCHW_PS0_32BITS|RCHW_VLE
00094 #else
00095 #define RCHW_VALUE RCHW_BOOTIDENTIFIER|RCHW_PS0_32BITS 
00096 #endif
00097 
00098 const unsigned long bam_rchw = (RCHW_VALUE)<<16;
00099 const resetfuncptr bam_resetvector = __startup;
00100 
00101 #pragma pop
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106